import React, { Component } from 'react';
import MySwiper from '../../../components/MySwiper'
import Recommend from './Recommend';

import {Button,Toast,Dialog} from 'antd-mobile'

import {connect} from 'react-redux'

class Home extends Component {
    
    handleClick(){
        //弹出 轻提示
        Toast.show({ icon:'success',   content:'新增成功!' })
    }
    handleClick2(){
        //弹出 对话框
        Dialog.confirm({ content:'考试还有1分钟结束!' }).then((res)=>{
            if( res ){
                console.log('点击了确定');
            }else{
                console.log('点击了取消');
            }
        })
    }
    render() {
        var {c} = this.props;
        return (
            <div className='home'>
                Home - { c }

                <Button onClick={this.handleClick}>弹出轻提示</Button>
                <Button onClick={this.handleClick2}>弹出对话框</Button>

                {/* 轮播图 */}
                <MySwiper />

                {/* 快捷分类 */}

                {/* 秒杀列表 */}

                {/* 推荐列表 */}
                <Recommend />

            </div>
        );
    }
}

//connect高阶组件, 负责将store中state数据, 方法以属性的形式写入到组件props中
export default connect(
    (state)=>{
        return {
            c: state.count
        }
    },
    (dispatch)=>{
        return {

        }
    }
)(Home);